Is it possible to Click a label control on WPF/WinForm App using Microsoft Automation UI

您所在的位置:网站首页 python uiautomation Is it possible to Click a label control on WPF/WinForm App using Microsoft Automation UI

Is it possible to Click a label control on WPF/WinForm App using Microsoft Automation UI

2023-04-04 03:15| 来源: 网络整理| 查看: 265

My hint is to use Button. It derives from ICommandSource interface and therefore you can effortlessly use Command to associate Button with handler. Ask yourself: what functionality does a Label provide that a Button does not? Better look? Override default Button's Template and you will get equivalent look. As long as you do not take advantage of any additional functionality of Label I see no point is messing around with it.

You got 3 options to solve this problem from my point of view:

UI Automation approach is to override the AutomationPeer of your component and return a ButtonAutomationPeer in your case. The big advantage here is beeing able to model every custom behaviour required. Microsoft's docu for further reading Use the ClickablePoint of your Label, and combine it with User32.dll (to fire the actual mouseclick on the provided coordinates). - see also microsoft mouse_event function docu for further details - This solution does not require any changes in your app but faces the following drawback: you won't be able to automate several apps simultaneously, if you don't build proper sub-routines on your own and you have to take care to keep the Application in the foreground (you may use the ShowWindow function from User32.dll for that). As already suggested by Maximus use a Button and make it look like a Label. I agree with him, that it should be a valid workaround in our case.


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3